import { createSlice } from '@reduxjs/toolkit'
import dayjs from 'dayjs'
export const dateslice = createSlice({
    name: 'counter',
    initialState: {
        date:dayjs().format('YYYY-MM-DD'),
        start:'北京',
        end:'广州'
    },
    reducers: {
        //    天数加1
        adddate(state, { payload }) {
            console.log('state.date',state.date)
            state.date=dayjs().add(1, 'day')
        },
        // 天数减1
        deldate(state, { payload }) {
            state.date=dayjs().subtract(1, 'day')
        },

    }
})
// 每个 case reducer 函数会生成对应的 Action creators
export const { adddate, deldate } = dateslice.actions

export default dateslice.reducer